class Solution {
public:

    void backtrack(vector<vector<int>>& results, vector<int>& res, vector<int>& nums){

        if(res.size() == nums.size()){
            results.push_back(res);
            return;
        }

        for(int i = 0; i < nums.size(); i++){
            if(check(res, nums[i])) continue;
            res.push_back(nums[i]);
            backtrack(results, res, nums, i);
            res.pop_back();
        }
    }

    bool check(vector<int>& res, int i){
        for(auto it: res){
            if(it==i) return true;
        }
        return false;
    }

    vector<vector<int>> permute(vector<int>& nums) {

        vector<vector<int>> result;
        vector<int> res;
        backtrack(result, res, nums);
    }
};